---
layout: "default"
title: "startsWith"
description: "Swift documentation for 'startsWith': Return true iff the the initial elements of s are equal to prefix."
keywords: "startsWith,func,swift,documentation"
root: "/v1.2"
---

<div class="declaration" id="func-startswith-s0_-sequencetype-s1_-sequencetype-where-s0-generator-element-s0-generator-element-s0-generator-element_-equatable_-s0-prefix_-s1">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-startswith-s0_-sequencetype-s1_-sequencetype-where-s0-generator-element-s0-generator-element-s0-generator-element_-equatable_-s0-prefix_-s1">func <wbr>startsWith&lt;S0 :<wbr> SequenceType, S1 :<wbr> SequenceType where S0.Generator.Element == S0.Generator.Element, S0.Generator.Element : Equatable&gt;(<wbr>_:<wbr> S0, prefix: S1)</a>
        
<div class="comment collapse" id="comment-func-startswith-s0_-sequencetype-s1_-sequencetype-where-s0-generator-element-s0-generator-element-s0-generator-element_-equatable_-s0-prefix_-s1"><div class="p">
    <p>Return true iff the the initial elements of <code>s</code> are equal to <code>prefix</code>.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func startsWith&lt;S0 : SequenceType, S1 : SequenceType where S0.Generator.Element == S0.Generator.Element, S0.Generator.Element : Equatable&gt;(s: S0, prefix: S1) -&gt; Bool</code>
    
    
</div></div>
</div>
<div class="declaration" id="func-startswith-s0_-sequencetype-s1_-sequencetype-where-s0-generator-element-s0-generator-element_-s0-prefix_-s1-isequivalent_-noescape-s0-generator-element-s0-generator-element-bool">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-startswith-s0_-sequencetype-s1_-sequencetype-where-s0-generator-element-s0-generator-element_-s0-prefix_-s1-isequivalent_-noescape-s0-generator-element-s0-generator-element-bool">func <wbr>startsWith&lt;S0 :<wbr> SequenceType, S1 : SequenceType where S0.Generator.Element == S0.Generator.Element&gt;(<wbr>_:<wbr> S0, prefix:<wbr> S1, isEquivalent: @noescape (S0.Generator.Element, S0.Generator.Element) -&gt; Bool)</a>
        
<div class="comment collapse" id="comment-func-startswith-s0_-sequencetype-s1_-sequencetype-where-s0-generator-element-s0-generator-element_-s0-prefix_-s1-isequivalent_-noescape-s0-generator-element-s0-generator-element-bool"><div class="p">
    <p>Return true iff <code>s</code> begins with elements equivalent to those of
<code>prefix</code>, using <code>isEquivalent</code> as the equivalence test.</p>

<p>Requires: <code>isEquivalent</code> is an <a href="http://en.wikipedia.org/wiki/Equivalence_relation">equivalence relation</a></p>

    <h4>Declaration</h4>    
    <code class="language-swift">func startsWith&lt;S0 : SequenceType, S1 : SequenceType where S0.Generator.Element == S0.Generator.Element&gt;(s: S0, prefix: S1, isEquivalent: @noescape (S0.Generator.Element, S0.Generator.Element) -&gt; Bool) -&gt; Bool</code>
    
    
</div></div>
</div>
